﻿using System.Collections.Generic;
using System.Linq;
using laba2.Entity;
using laba2.Repository.IRepository;

namespace laba2.Repository.RepositoryImpl
{
    public class TaskRepository:Repository<Task>, ITaskRepository
    {
        public TaskRepository(List<Task> list) : base(list)
        {
        }

        public List<Task> GetByName(string name)
        {
            return (from task in _list
                   where task.Name == name
                   select task).ToList();
        }

        public List<PracticalTask> GetAllPracticalTasks()
        {
            return (from task in _list
                    where task is PracticalTask
                    select (PracticalTask)task).ToList();
        }

        public List<BoundaryControl> GetAllBoundaryControls()
        {
            return(from task in _list
                  where task is BoundaryControl
                  select (BoundaryControl)task).ToList();
        }

        public List<FinalControl> GetAllFinalControls()
        {
            return(from task in _list
                  where task is FinalControl
                  select (FinalControl)task).ToList();
        }

        public List<Task> GetTasksByCourse(Course course)
        {
            return (from task in _list
                    where task.Course.Equals(course)
                    select task).ToList();
        }

        public List<Task> GetTasksByCourseId(int id)
        {
            return (from task in _list
                    where task.Course.Id==id
                    select task).ToList();
        } 
    }
}
